/**
 * @param {string} type = "Ponit"| "LineString"| "Polygon"
 */

export function createDraw({
    type = "Point",
    source,
    success
}){
    let geometryFunction = null
    let maxPoints = null
    let draw = new ol.interaction.Draw({
        type,
        source,geometryFunction,
        maxPoints
    })
    if(typeof success === "function"){
        //返回的就是要素
        draw.on("drawend", evt=>{
            success(evt.feature)
        })
    }
    return draw
}